package moe.oil.api.databaseAPI;

import moe.oil.dto.school.SchoolDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@FeignClient(name = "database-service",contextId = "SchoolAPI")
public interface SchoolAPI {
    // 添加学校
    @PostMapping("/school")
    public SchoolDTO addSchool(@Validated @RequestBody SchoolDTO schoolDTO);


    // 查询全部学校
    @GetMapping("/school/{page}/{size}")
    public List<SchoolDTO> getAllSchool(@PathVariable("page") int page, @PathVariable("size") int size);


    // 根据ID查询
    @GetMapping("/school/{id}")
    public SchoolDTO findById(@PathVariable("id") Long schoolId);

    // 根据Name查询学校
    @GetMapping("/school/query")
    public SchoolDTO findBySchoolName(@RequestBody SchoolDTO schoolDTO);

    // 修改学校
    @PutMapping("/school")
    public SchoolDTO updateSchool(@Validated @RequestBody SchoolDTO schoolDTO);

    // 根据ID删除学校
    @DeleteMapping("/school/{id}")
    public int deleteSchool(@PathVariable("id") Long schoolId);



}
